from abc import abstractmethod
from typing import Dict, Any, Optional
import torch
from ....core.component import ComponentInterface


class CombinerInterface(ComponentInterface):
    """
    Interface for stateless combination strategies.

    This interface defines pure functions for combining task outputs without
    maintaining any internal state. Each combination operation is independent
    and deterministic based solely on the provided inputs.

    All methods are stateless and can be called independently without
    side effects on the combiner instance.
    """

    @abstractmethod
    def combine(
        self,
        outputs: Dict[str, torch.Tensor],
        weights: torch.Tensor,
        context: Optional[Dict[str, Any]] = None,
        **kwargs,
    ) -> Dict[str, torch.Tensor]:
        """
        Combine outputs from multiple tasks.

        Args:
            outputs: Dictionary mapping task_id to output tensor
            weights: Dictionary mapping task_id to combination weight
            context: Optional context for combination
            **kwargs: Additional combination parameters

        Returns:
            torch.Tensor: Combined output tensor
        """
        pass
